import request from '@/utils/request'

// 查询社区话题列表
export function listCommunityTopic(query, pageReq) {
  return request({
    url: '/community/topic/list',
    method: 'post',
    data: query,
    params: pageReq
  })
}

// 查询社区话题详细
export function getCommunityTopic(id) {
  return request({
    url: '/community/topic/' + id,
    method: 'get'
  })
}

// 新增社区话题
export function addCommunityTopic(data) {
  return request({
    url: '/community/topic',
    method: 'post',
    data: data
  })
}

// 修改社区话题
export function updateCommunityTopic(data) {
  return request({
    url: '/community/topic',
    method: 'put',
    data: data
  })
}

// 删除社区话题
export function delCommunityTopic(id) {
  return request({
    url: '/community/topic/' + id,
    method: 'delete'
  })
}

// 导出社区话题
export function exportCommunityTopic(query) {
  return request({
    url: '/community/topic/export',
    method: 'get',
    params: query
  })
}

// 获取话题统计信息
export function getTopicStatistics(id) {
  return request({
    url: '/community/topic/' + id + '/statistics',
    method: 'get'
  })
}

// 批量更新话题状态
export function batchUpdateTopicStatus(data) {
  return request({
    url: '/community/topic/batch/status',
    method: 'put',
    data: data
  })
}

// 获取热门话题
export function getHotTopics(limit = 10) {
  return request({
    url: '/community/topic/hot',
    method: 'get',
    params: { limit }
  })
}

// 搜索话题
export function searchTopics(keyword) {
  return request({
    url: '/community/topic/search',
    method: 'get',
    params: { keyword }
  })
}